<%@tag  pageEncoding="UTF-8" import="java.util.List, java.util.Map, ajaxjs.data.Field"%>
<%@attribute name="zeroCountText" fragment="true" required="false"%> 
<%@attribute name="simpleTable_noPic" required="false" type="java.lang.Boolean"%> 
<%@attribute name="serviceObj" 		required="true"  type="ajaxjs.data.service.Service" description="业务层"%> 
<%
	Map<String, String> labels = Field.initInfEdit(serviceObj, request);
%>
<div class="listContent">
	<p class="toolbar crudAction">
		<button class="btn refreshBtn">刷新</button>
		<button class="btn btn-warning viewEntryBtn">查看</button>
		<button class="btn btn-info createEntryBtn">添加${metaInfo.ns_name}</button>
		<button class="btn btn-primary modiflyEntryBtn">修改</button>
		<button class="btn btn-danger delEntryBtn">删除</button>
		<%
		if(labels.get("catalog") != null){ 
		%>
		<button class="btn btn-success catalogMgrBtn">${metaInfo.ns_name}${labels.catalog}管理</button>
		<%}%>
 	</p>
  	<table class="list table table-bordered table-striped with-check">
		<thead>
			<tr>
 				<th width="10"><input type="checkbox" class="selectAllBtn" /> </th>

				<%for(String id : labels.keySet()) {%>
					<th class="<%=id%>"><%=labels.get(id)%></th>
				<%} %>
				<th>状态操作</th>
				<%if(simpleTable_noPic == null) {%>
				<th class="imgs">相册管理</th>
				<%}%>
			</tr>
		</thead>
		<tbody id="listContainer" class="tableBody"></tbody>
	</table>

	<div class="pager">
		<button class="perv">上一页</button>
		<span style="display: none;">{pageNo}/{pages} 页
			${metaInfo.ns_name}总记录数:{totalCount}</span>
		<button class="next">下一页</button>
	</div>
	<div class="dataNotFound" style="display: none; text-align: center;">
		<jsp:invoke fragment="zeroCountText" /> 
	</div>
</div>

<textarea id="listUl" style="display:none;">
	<tpl>
		<tr class="entryId_{id}">
			<td class="alignCenter"><input type="checkbox" /></td>			
 
			<%for(String id : labels.keySet()) {%>
				<td title="<%=labels.get(id)%>" class="<%=id%>">{<%=Field.getCatalogName(serviceObj, labels, id)%>}</td>
			<% }%>
			<td class="alignCenter">
				当前状态：<span>{[isHidden == 0 || !isHidden ? '下架中' :'上线中' ]}</span>| 
				<a href="javascript:;" class="stateControl">{[isHidden == 0 || !isHidden ? '上线' :'下架' ]}此${metaInfo.ns_name}</a>
			</td>
			<%if(simpleTable_noPic == null){ %>
			<td class="alignCenter imgs">
				<a href="javascript:;" class="uploadPicBtn">${metaInfo.ns_name}图片</a>
			</td>
			<%} %>
		</tr>
	</tpl>
</textarea>

<%@taglib prefix="commonUI" tagdir="/WEB-INF/tags/common/UI"%>
<%if(labels.get("catalog") != null){ %>
<commonUI:baseDialog title="分类管理" className="catalogMgr" isEntityDlg="false">
	<jsp:attribute name="btns">
		<button class="closeAction middleBtn stdBtn" title="关闭对话框">关闭</button>
	</jsp:attribute>
	
	<jsp:body>
		<br />
		<div class="list"></div>
		<br />
		<div>
			<input type="text" name="key" placeholder="添加新分类之 ID" tipsMsg="添加新分类之 ID" requiredField="true" />
			<input type="text" name="name" placeholder="添加新分类之 名称" requiredField /><button>添加新分类</button>
			<input type="hidden" name="belongsTo" value="${metaInfo.ns_id}" />
		</div>
		<br />
		
	</jsp:body>
	
</commonUI:baseDialog>

<textarea class="catalogItemTpl hide">
	<ul>
		<tpl>
			<li>{name} 
				<a href="#" class="id_{id}">× 删除</a> 
				<a target="iframepage" onclick="document.body.removeChild(document.querySelector('.catalogMgr'));" 
				href="../public/catalog.jsp?id={id}&belongsto={belongsTo}">详细</a></li>
		</tpl>
	</ul>
</textarea>
<%}%>